package com.company;



public class Hunter {
    String name;
    String job;
    int maxLife;
    int curLife;
    boolean isLive;
    String weapon;
    int attack;
    int defend;         
    int level;
    int exp;
    int agile;
    int hideRate;
    int treasure;

    public Hunter(String name,String job,String weapon){
        this.name = name;
        this.job = job;
        this.weapon = weapon;
        maxLife = 100;
        curLife = maxLife;
        isLive = true;
        attack = 25;
        defend = 8;
        level = 1;
        exp = 0;
        agile = 35;
        hideRate = 60;
        treasure = 0;
    }
    public void fight(Monster monster){
        if(monster.isLive){
            if(isLive){
                System.out.println(monster.type+"被发现了");
                System.out.println(job+name+"拿起"+weapon+"背刺了"+monster.type);
                monster.injured(this);
            }else{
                System.out.println("啊啊啊,"+name+"陨落");
            }
        }else
        {
            System.out.println("红巾狗贼，摸了摸了");
        }
    }

    public void injured(Monster monster){

        if(monster.type == "弗莱迪"){
            if(GameUtil.hidden(this.agile,this.hideRate)){
                System.out.println(name+":多捞啊");
                show();
                fight(monster);
                return;
            }
            System.out.println(name+"看了一眼表：才八点");
            int lostLife = GameUtil.calLostLife(monster.attack, this.defend);
            curLife-=lostLife;
            if(curLife<0){
                curLife=0;
                died();
                return;
            }
            monster.curLife+=this.curLife/10;
            show();
            fight(monster);
        }else{
            if(GameUtil.hidden(this.agile,this.hideRate)){
                System.out.println(name+"这波，这波是肉蛋葱鸡");
                show();
                fight(monster);
                return;
            }
            System.out.println(name+"大吼着“卡其脱离太，莫呐莫呐一”燃起了斗志");
            int lostLife = GameUtil.calLostLife(monster.attack, this.defend);
            curLife-=lostLife;
            if(curLife<0){
                curLife=0;
                died();
                return;
            }
            show();
            fight(monster);
        }
    }
    public void expAdd(Monster monster){
        this.exp+=monster.maxLife;
        int needExp = 0;
        for(int i=1;i<=level;i++){
            needExp+=i*50;
        }
        if(exp>=needExp){
            upgrade();
        }

    }
    public void upgrade(){
        attack+=4;
        defend+=3;
        maxLife+=20;
        curLife+=maxLife;
        level++;
        System.out.println("经过一番激烈的战斗你感到自己又强大了");
        if(level>=20){
            System.out.println("你在传奇的道路上越走越远。");
        }
    }
    public void died(){
        System.out.println(name+"被撒死了");
        isLive = false;
        show();
    }
    public void show(){
        System.out.println(name+"：生命值:"+curLife);
        System.out.println("、、、、、、、、、、我是奇妙的分割线、、、、、、、、、、");
    }

}
